package com.twu.biblioteca;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Movies {
    public Map<String,String> movieTable = new HashMap<String, String >();
    public List<String> movieList = new ArrayList<String>();

    public Movies() {
        this.addMovie();
    }

    public String showList() {
        String result = "";
        int index = 1;
        for (String name : movieTable.keySet()) {
            result += index + "." + name + "\n";
            index++;
        }
        return result;
    }

    public void addMovie() {
        File file = new File("bin/movie_list.txt");
        try {
            BufferedReader buffer = new BufferedReader(new FileReader(file));
            String line;
            while ((line = buffer.readLine()) != null) {
                line = line.substring(2,line.length());
                movieTable.put(line, "");
                movieList.add(line);
            }
            buffer.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
